package com.MLC.controller;

import com.MLC.entity.Consultant;
import com.MLC.service.ConsultantService;
import com.MLC.service.LoginService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;


@Controller
public class LoginController {
    @Autowired
    private LoginService loginService;
    @Autowired
    private ConsultantService consultantService;
    private static final Logger logger = LogManager.getLogger(LoginController.class.getName());
    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public ModelAndView hello() {
        ModelAndView mv = new ModelAndView("Login/Login");
        return mv;
    }

    @RequestMapping(value = "/sayhello", method = RequestMethod.GET)
    @ResponseBody
    public String sayHello() {
        logger.info("this is sayHello function!");
        Consultant consultant=new Consultant();
        consultant.setUsername("17722656616");
        consultant.setPhone("17722656615");
        consultant.setPassword("Steven1234");
        consultant.setCompanyName("华商林李黎");
        consultant.setCompanyPosition("律师助理");
        consultant.setEmail("1043521500@qq.com");
        consultantService.saveConsultant(consultant);
        String ret=loginService.Login();
//        String ret="hello mini program";
        return ret;
    }

}
